package com.ruoyi.system.mapper;

import java.util.List;
import java.util.Map;

import com.ruoyi.system.domain.ProvideRecords;
import com.ruoyi.system.domain.excel.ProvideRecordsdExcel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 配件库开票明细Mapper接口
 * 
 * @author ruoyi
 * @date 2024-05-07
 */
public interface ProvideRecordsMapper 
{
    /**
     * 查询配件库开票明细
     * 
     * @param id 配件库开票明细主键
     * @return 配件库开票明细
     */
    public ProvideRecords selectProvideRecordsById(Long id);

    /**
     * 查询配件库开票明细列表
     * 
     * @param provideRecords 配件库开票明细
     * @return 配件库开票明细集合
     */
    public List<ProvideRecords> selectProvideRecordsList(ProvideRecords provideRecords);

    /**
     * 新增配件库开票明细
     * 
     * @param provideRecords 配件库开票明细
     * @return 结果
     */
    public int insertProvideRecords(ProvideRecords provideRecords);

    public int insertBatch(List<ProvideRecords> provideRecordsList);



    /**
     * 修改配件库开票明细
     * 
     * @param provideRecords 配件库开票明细
     * @return 结果
     */
    public int updateProvideRecords(ProvideRecords provideRecords);

    /**
     * 删除配件库开票明细
     * 
     * @param id 配件库开票明细主键
     * @return 结果
     */
    public int deleteProvideRecordsById(Long id);

    /**
     * 批量删除配件库开票明细
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteProvideRecordsByIds(Long[] ids);

    public List<String> selectProductCode(@Param("list")List<String> productList);


    public List<Map<String,Object>> selectWareMoney(@Param("wareHouseCode")String wareHouseCode,@Param("createTime")String createTime,@Param("provide")String provide);
    public List<Map<String,Object>> selectOutWareMoney(@Param("wareHouseCode")String wareHouseCode,@Param("createTime")String createTime,@Param("provide")String provide);

    public Double selectSumMoney(@Param("provide")String provide,@Param("createTime")String createTime,@Param("wareHouseCode")String warehouseCode);

    public Double setlectSumProductMoney(@Param("provide")String provide,@Param("createTime")String createTime,@Param("wareHouseCode")String warehouseCode);

    public List<Map<String,Object>> selectProvideWareMoney(@Param("createTime")String createTime,@Param("provide")String provide);

    public List<String> selectProvideList(@Param("provide")String provide);

    @Select("<script>" +
            "select sum(product_money)inMoney,sum(product_price*product_count)outMoney from provide_records where 1=1 " +
            "<if test=\"startTime!=null and startTime!= ''\">" +
            " and create_time = #{startTime} " +
            "</if>" +
            "</script>")
    public List<Map<String,Object>>  selectSumProfitMoney(@Param("startTime")String startTime);

    @Select("delete from provide_records where create_time = #{time}")
    public Integer deleteUpload(@Param("time")String time);

    public List<ProvideRecordsdExcel> selectProvideExcelList(ProvideRecords provideRecords);

    @Select("<script>" +
            "select sum(product_money)allMoney from provide_records where 1=1 " +
            "<if test=\"startTime!=null and startTime!= ''\">" +
            " and create_time = #{startTime} " +
            "</if>" +
            "<if test=\"provide!=null and provide!= ''\">" +
            " and provide = #{provide} " +
            "</if>" +
            "</script>")
    public Double selectAllMoney(@Param("provide")String provide,@Param("startTime")String startTime);

    @Select("<script>" +
            "select sum(product_price*product_count)allMoney from provide_records where 1=1 " +
            "<if test=\"startTime!=null and startTime!= ''\">" +
            " and create_time = #{startTime} " +
            "</if>" +
            "<if test=\"provide!=null and provide!= ''\">" +
            " and provide = #{provide} " +
            "</if>" +
            "</script>")
    public Double selectMoney(@Param("provide")String provide,@Param("startTime")String startTime);

    @Select("<script>" +
            "select sum(plarn_price*product_count)allMoney from provide_records where 1=1 " +
            "<if test=\"startTime!=null and startTime!= ''\">" +
            " and create_time = #{startTime} " +
            "</if>" +
            "<if test=\"provide!=null and provide!= ''\">" +
            " and provide = #{provide} " +
            "</if>" +
            "</script>")
    public Double selectAllMoneyPrice(@Param("provide")String provide,@Param("startTime")String startTime);

    @Select("<script>" +
            "select sum(product_count)allMoney from provide_records where 1=1 " +
            "<if test=\"startTime!=null and startTime!= ''\">" +
            " and create_time = #{startTime} " +
            "</if>" +
            "<if test=\"provide!=null and provide!= ''\">" +
            " and provide = #{provide} " +
            "</if>" +
            "</script>")
    public Double selectAllMoneyCount(@Param("provide")String provide,@Param("startTime")String startTime);

    @Select("<script>" +
            "select sum(plarn_price*product_count)allMoney from provide_records where 1=1 and provide ='上海宇申' and product_code in ('63021101106410','63021101096410','63021101086410') " +
            "<if test=\"startTime!=null and startTime!= ''\">" +
            " and create_time = #{startTime} " +
            "</if>" +
            "</script>")
    public Double selectYSMoneyPrice3(@Param("startTime")String startTime);

    @Select("<script>" +
            "select sum(plarn_price*product_count)allMoney from provide_records where 1=1 and provide ='上海宇申' and product_code not in ('63021101106410','63021101096410','63021101086410') " +
            "<if test=\"startTime!=null and startTime!= ''\">" +
            " and create_time = #{startTime} " +
            "</if>" +
            "</script>")
    public Double selectYSMoneyPrice10(@Param("startTime")String startTime);

    @Select("<script>" +
            "select sum(plarn_price*product_count)allMoney from invoice_records where 1=1 and provide ='上海盛丹' and product_code not in('5107071088531','5107071090531','5107071092531','5107071088532','5107071090532','5107071092532','7411670165031','7311010463716') " +
            "<if test=\"startTime!=null and startTime!= ''\">" +
            " and create_time = #{startTime} " +
            "</if>" +
            "</script>")
    public Double selectSDMoneyPrice(@Param("startTime")String startTime);

    @Select("<script>" +
            "select sum(plarn_price*product_count)allMoney from provide_records where 1=1 and provide ='上海盛丹' and product_code not in('5107071088531','5107071090531','5107071092531','5107071088532','5107071090532','5107071092532','7411670165031','7311010463716') " +
            "<if test=\"startTime!=null and startTime!= ''\">" +
            " and create_time = #{startTime} " +
            "</if>" +
            "</script>")
    public Double selectSDMoneyPt(@Param("startTime")String startTime);

    @Select("<script>" +
            "select sum(169*product_count)allMoney from invoice_records where 1=1 and provide ='上海盛丹' and product_code = '7411670165031' " +
            "<if test=\"startTime!=null and startTime!= ''\">" +
            " and create_time = #{startTime} " +
            "</if>" +
            "</script>")
    public Double selectSDMoneyLT(@Param("startTime")String startTime);

    @Select("<script>" +
            "select sum(plarn_price*product_count)allMoney from invoice_records where 1=1 and provide ='上海盛丹' and product_code in ('7311010463716') " +
            "<if test=\"startTime!=null and startTime!= ''\">" +
            " and create_time = #{startTime} " +
            "</if>" +
            "</script>")
    public Double selectSDMoneyPriceRHY(@Param("startTime")String startTime);

    @Select("<script>" +
            "select sum(plarn_price*product_count)allMoney from invoice_records where 1=1 and provide ='上海永售' and product_code in ('7311010463714') " +
            "<if test=\"startTime!=null and startTime!= ''\">" +
            " and create_time = #{startTime} " +
            "</if>" +
            "</script>")
    public Double selectYSMoneyPriceRHY(@Param("startTime")String startTime);

    @Select("<script>" +
            "select sum(plarn_price*product_count)allMoney from provide_records where 1=1 and provide ='上海永售' and product_code not in('7311010463714') " +
            "<if test=\"startTime!=null and startTime!= ''\">" +
            " and create_time = #{startTime} " +
            "</if>" +
            "</script>")
    public Double selectYSMoneyPricePt(@Param("startTime")String startTime);

    @Select("<script>" +
            "select sum(plarn_price*product_count)allMoney from invoice_records where 1=1 and provide ='上海永售' and product_code not in ('7311010463714') " +
            "<if test=\"startTime!=null and startTime!= ''\">" +
            " and create_time = #{startTime} " +
            "</if>" +
            "</script>")
    public Double selectYSMoneyPrice(@Param("startTime")String startTime);

    @Select("<script>" +
            "select sum(plarn_price*product_count)allMoney from invoice_records where 1=1 and provide ='祥皓贸易' and product_code not in ('3101005218124S','3101005221124S','3101005223124S','3101005229124S')" +
            "<if test=\"startTime!=null and startTime!= ''\">" +
            " and create_time = #{startTime} " +
            "</if>" +
            "</script>")
    public Double selectXHMoneyPriceZXK(@Param("startTime")String startTime);

    @Select("<script>" +
            "select sum(plarn_price*product_count)allMoney from provide_records where 1=1 and provide ='祥皓贸易' and product_code not in ('3101005218124S','3101005221124S','3101005223124S','3101005229124S')" +
            "<if test=\"startTime!=null and startTime!= ''\">" +
            " and create_time = #{startTime} " +
            "</if>" +
            "</script>")
    public Double selectXHMoneyPrice(@Param("startTime")String startTime);

    @Select("<script>" +
            "select sum(product_count)allMoney from invoice_records where 1=1 and provide ='上海豫东' and product_code in ('29971571023010','29971571043010')" +
            "<if test=\"startTime!=null and startTime!= ''\">" +
            " and create_time = #{startTime} " +
            "</if>" +
            "</script>")
    public Double selectYDMoneyPrice(@Param("startTime")String startTime);

    @Select("<script>" +
            "select sum(plarn_price*product_count)allMoney from invoice_records where 1=1 and provide ='上海豪贤' and product_code not in('73111790018020') " +
            "<if test=\"startTime!=null and startTime!= ''\">" +
            " and create_time = #{startTime} " +
            "</if>" +
            "</script>")
    public Double selectHXMoneyPrice(@Param("startTime")String startTime);

    @Select("<script>" +
            "select sum(plarn_price*product_count)allMoney from invoice_records where 1=1 and provide ='上海豪贤' and product_code = '73111790018020' " +
            "<if test=\"startTime!=null and startTime!= ''\">" +
            " and create_time = #{startTime} " +
            "</if>" +
            "</script>")
    public Double selectHXMoneyRHY(@Param("startTime")String startTime);

    @Select("<script>" +
            "select sum(plarn_price*product_count)allMoney from invoice_records where 1=1 and provide ='上海帕尔茨' and product_code = '73111710180420' " +
            "<if test=\"startTime!=null and startTime!= ''\">" +
            " and create_time = #{startTime} " +
            "</if>" +
            "</script>")
    public Double selectPRCMoneyRHY(@Param("startTime")String startTime);

    @Select("<script>" +
            "select sum(plarn_price*product_count)allMoney from invoice_records where 1=1 and provide ='鼎厉' and product_code = '73111780908420' " +
            "<if test=\"startTime!=null and startTime!= ''\">" +
            " and create_time = #{startTime} " +
            "</if>" +
            "</script>")
    public Double selectDLMoneyRHY(@Param("startTime")String startTime);

    @Select("<script>" +
            "select sum(plarn_price*product_count)allMoney from invoice_records where 1=1 and provide ='上海友瑗' and product_code = '73111790188620' " +
            "<if test=\"startTime!=null and startTime!= ''\">" +
            " and create_time = #{startTime} " +
            "</if>" +
            "</script>")
    public Double selectYYMoneyRHY(@Param("startTime")String startTime);
}
